<template>
  <div class="login-container">
    <div class="login-form-wrap">
      <div class="login-head">
        <div class="logo"></div>
      </div>
      <el-form class="login-form" ref="login-form" :model="user" :rules="formRules">
        <el-form-item prop="mobile">
          <el-input v-model="user.mobile" placeholder="请输入手机号"></el-input>
        </el-form-item>
        <el-form-item prop="code">
          <el-input v-model="user.code" placeholder="请输入验证码"></el-input>
        </el-form-item>
        <el-form-item prop = "agree"> 
          <el-checkbox v-model="user.agree">我已阅读并同意用户协议和隐私条款</el-checkbox>
        </el-form-item>
        <el-form-item>
          <el-button class="login-btn" type="primary" @click="onLogin" :loading="loginLoading">登录</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: "LoginIndex",
  data() {
    return {
      user: {
        mobile: "13911111111", //手机号
        code: "246810", //验证码
        agree: false
      },
      loginLoading: false, //登录的 loading状态
      formRules: {
        // 表单验证规则配置
        // 要验证的数据名称：规则列表[]
        mobile: [
          { required: true, message: "请输入手机号", trigger: "change"},
          { pattern: /^1[3|5|7|8|9]\{9}$/, message: "请输入正确的号码格式", trigger: "change"}
        ],
        code: [
          { required: true, }
        ]
      }
    }
  },
  methods: {
    remove() {}
  }
}
</script>

<style scoped lang = "less">
.login-container {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: url("./login_bg.jpg") no-repeat;
  background-size: cover;
  .login-form-wrap {
    background-color: #fff;
    padding: 30px 50px 10px;
    min-width: 300px;
  }
  .login-head {
    display: flex;
    justify-content: center;
    .logo {
      width: 200px;
      height: 57px;
      background: url("./logo_index.png") no-repeat;
      background-size: contain;
    }
  }
  .login-form {
    .login-btn {
      width: 100%;
    }
  }
}
</style>